package com.demo.client;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * notification 的广播接收器
 * 
 * @author Administrator
 *
 */
public class NotificationReceiver extends BroadcastReceiver {

	private static final String TAG = LogUtil.getClassName(NotificationReceiver.class);
	
	@Override
	public void onReceive(Context context, Intent intent) {
		
		Log.d(TAG, "Notification.onReceive()....");
		String action = intent.getAction();
		Log.d(TAG, "Notification action:"+action);
		
		if(Constants.ACTION_SHOW_NOTIFICATION.equals(action))
		{
			String id = intent.getStringExtra(Constants.NOTIFICATION_ID);
			String apiKey = intent.getStringExtra(Constants.NOTIFICATION_API_KEY);
			String title = intent.getStringExtra(Constants.NOTIFICATION_TITLE);
			String message = intent.getStringExtra(Constants.NOTIFICATION_MESSAGE);
			String uri = intent.getStringExtra(Constants.NOTIFICATION_URI);
			
			Log.d(TAG, "Notification Receive ..id:"+id);
			Log.d(TAG, "Notification Receive ..apiKey:"+apiKey);
			Log.d(TAG, "Notification Receive ..title:"+title);
			Log.d(TAG, "Notification Receive ..message:"+message);
			Log.d(TAG, "Notification Receive ..uri:"+uri);
			
			Notifier notifier = new Notifier(context);
			notifier.notifyMessage(id,apiKey,title,message,uri);
			
		}
	}
}
